package com.example.sys.controller;


import com.example.common.bean.R;
import com.example.common.util.Select;
import com.example.sys.entity.User;
import com.example.sys.service.UserService;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ZhengDing
 * @since 2022-01-28 09:31:36
 */
@RestController
@RequestMapping("/sys/user")
public class UserController {

    @Autowired
    UserService userService;

    @GetMapping("get")
    public R<User> get(@ApiParam(defaultValue = "1") Integer id) {
        if (id == null) {
            id = 1;
        }
        User user = userService.getById(id);
        return R.OK(user);
    }
    
    @PostMapping("save")
    public R save(@RequestBody User user) {
        userService.save(user);
        return R.OK();
    }
}
